#ifndef __DOUBLELINKLIST_H_
#define __DOUBLELINKLIST_H_

#include <stdbool.h>

#define ElementType int

typedef struct Node
{
    ElementType data; //存储的数据
    struct Node* prev;//前继节点
    struct Node* next;//后继节点 
}Node;

typedef struct DoubleLinkList
{
    struct Node* head;//头指针，无头结点
    struct Node* tail;//尾指针，无头结点
    int len;          //有效节点个数
}DLlist;

//初始化
int DLlistInit(DLlist* list);
//销毁双向链表
void DLlistDestroy(DLlist* list);
//打印
void DLlistPrint(DLlist* list);
//尾插
void DLlistInsertTail(DLlist* list, ElementType element);
//头插
void DLlistInsertHead(DLlist* list, ElementType element);
//尾删
void DLlistPopBack(DLlist* list);
//头删
void DLlistPopFront(DLlist* list);
//按下标插入
DLlist* DLlistInsertByIndex(DLlist* list, ElementType element, int index);
//按位删除
void DLlistRemoveByIndex(DLlist* list, int index);
//查找第一个值符合的元素
int DLlistFindFirstByElement(DLlist* list, ElementType element);
//按值删除
void DLlistRemoveByElement(DLlist* list, ElementType element);
//查找下标所对应的值
ElementType DLlistFindByIndex(DLlist* list, int index);
//通过下标设定值
void DLlistSetValueByIndex(DLlist* list, int index, ElementType element);
//更改元素值
void DLlistSetValueByElement(DLlist* list, ElementType oldValue, ElementType newValue); 


#endif